package cn.youyeku.sockettransmission.ui;

import android.os.Bundle;
import android.os.StrictMode;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import cn.youyeku.sockettransmission.R;
import cn.youyeku.sockettransmission.adapter.ViewPagerAdapter;
import cn.youyeku.sockettransmission.ui.fragment.ConfigureFragment;
import cn.youyeku.sockettransmission.ui.fragment.ChatFragment;

public class MainActivity extends AppCompatActivity {


    private ViewPagerAdapter mViewPagerAdapter;
    private ViewPager mMainViewPage;
    private TabLayout mViewPageTabs;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
//初始化支持4.0之前的fgm适配器
        mViewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
        mViewPagerAdapter.addFragment(new ChatFragment(), "文件传输");
        mViewPagerAdapter.addFragment(new ConfigureFragment(), "配置文件");
        mMainViewPage.setAdapter(mViewPagerAdapter);
        mMainViewPage.setOffscreenPageLimit(2);
        mViewPageTabs.setupWithViewPager(mMainViewPage);


//        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
//                .permitAll().build();
//        StrictMode.setThreadPolicy(policy);

    }

    private void initView() {
        mMainViewPage = (ViewPager) findViewById(R.id.main_view_page);
        mViewPageTabs = (TabLayout) findViewById(R.id.view_page_tabs);
    }
}
